<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                template="/templates/ui.xhtml">

<ui:define name="head">
    <title>成本列支查询</title>
    <script type="text/javascript" src="#{request.contextPath}/UI/support/pub.js"/>
    <script type="text/javascript" language="javascript">
        document.onkeydown = function TabReplace() {
            if (event.keyCode == 13) {
                if (event.srcElement.tagName != 'BUTTON')
                    event.keyCode = 9;
                else
                    event.srcElement.click();
            }
        }
    </script>
</ui:define>
<ui:define name="content">
<div style="margin:5px;">
<h:form id="form" enctype="multipart/form-data">
<p:growl id="msgs" showDetail="true"/>
<p:focus for="id"/>
<p:panel id="ppCondition" style="width: 100%">
    <h:panelGrid columns="2" style="width: 100%">
        <h:panelGrid id="pgCust" widgetVar="WvCust" columns="4" style="text-align: right;">
            <h:outputLabel value="纳税人识别号:" for="id" style="font-weight: bold"/>
            <p:inputText id="id" value="#{costAction.queryCondition.taxerID}"/>

            <h:outputLabel value="纳税人名称:" for="name" style="font-weight: bold;margin-left: 100px;"/>
            <p:inputText id="name" value="#{costAction.queryCondition.taxerName}"/>

            <h:outputLabel value="所属日期起:" for="startDate" style="font-weight: bold"/>
            <p:inputText id="startDate" value="#{costAction.queryCondition.dateStart}"
                         onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})"/>

            <h:outputLabel value="所属日期止:" for="endDate" style="font-weight: bold"/>
            <p:inputText id="endDate" value="#{costAction.queryCondition.dateEnd}"
                         onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})"/>

            <h:outputLabel value="所属税务机关:" for="taxOrgan" style="font-weight: bold"/>
            <p:inputText id="taxOrgan" value="#{costAction.queryCondition.taxAuthority}"/>

            <h:outputLabel value="主管税务管员:" for="taxManager" style="font-weight: bold"/>
            <p:inputText id="taxManager" value="#{costAction.queryCondition.taxManager}"/>

            <h:outputLabel value="成本类型:" for="costType" style="font-weight: bold"/>
            <p:selectOneMenu id="costType" value="#{costAction.queryCondition.costType}"
                             style="width: 145px;">
                <f:selectItem itemLabel="" itemValue=""/>
                <f:selectItem itemLabel="销售费用" itemValue="0074"/>
                <f:selectItem itemLabel="其它费用" itemValue="0075"/>
                <f:selectItem itemLabel="前期工程费" itemValue="0076"/>
                <f:selectItem itemLabel="购买土地费用" itemValue="0071"/>
                <f:selectItem itemLabel="规划设计费用" itemValue="0072"/>
                <f:selectItem itemLabel="施工建设费用" itemValue="0073"/>
                <f:selectItem itemLabel="开发间接费用" itemValue="0081"/>
                <f:selectItem itemLabel="基础设施建设费" itemValue="0077"/>
                <f:selectItem itemLabel="公共配套设施费" itemValue="0078"/>
                <f:selectItem itemLabel="建筑安装工程费" itemValue="0080"/>
                <f:selectItem itemLabel="土地征用及拆迁费" itemValue="0079"/>
            </p:selectOneMenu>

        </h:panelGrid>
        <h:panelGrid style="width:10%">
            <p:commandButton id="qryBtn" value="查 询" actionListener="#{costAction.query()}"
                             style="font-size: 14px;width: 80px;" update="tabSum,msgs">
            </p:commandButton>
            <p:commandButton id="resetBtn" type="reset" value="重 置"
                             style="font-size: 14px;width: 80px;">
            </p:commandButton>
        </h:panelGrid>
    </h:panelGrid>
</p:panel>
<p:ajaxStatus style="width:16px;height:16px;">
    <f:facet name="start">
        <h:graphicImage value="/images/ajaxloading.gif"/>
    </f:facet>
    <f:facet name="complete">
        <h:outputText value=""/>
    </f:facet>
</p:ajaxStatus>
<p:dataTable id="tabSum" style="width:100%;"
             value="#{costAction.costInfos}"
             var="costInfo"
             rowKey="#{costInfo.pkid}"
             selectionMode="single"
             selection="#{costAction.costInfoSelected}"
             paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
             paginator="true"
             paginatorPosition="bottom"
             rows="15"
             rowsPerPageTemplate="100,50,30,15,5"
             emptyMessage="数据记录为空..."
             widgetVar="tabSumVar">

    <p:ajax event="rowSelect" listener="#{costAction.updateThcostInfo()}" update=":form:tabDetail"/>

    <p:column style="text-align:center" sortBy="#{costInfo.NSRSBH}">
        <f:facet name="header">
            <h:outputText value="纳税人识别号"/>
        </f:facet>
        <h:outputText value="#{costInfo.NSRSBH}"/>
    </p:column>

    <p:column style="text-align:center" filterBy="#{costInfo.NSRMC}" filterMatchMode="contains">
        <f:facet name="header">
            <h:outputText value="纳税人名称"/>
        </f:facet>
        <h:outputText value="#{costInfo.NSRMC}"/>
    </p:column>

    <p:column style="text-align:center" filterBy="#{costInfo.costItem}" filterMatchMode="contains">
        <f:facet name="header">
            <h:outputText value="开票项目"/>
        </f:facet>
        <h:outputText value="#{costInfo.costItem}"/>
    </p:column>

    <p:column style="text-align:center" sortBy="#{costInfo.costCount}">
        <f:facet name="header">
            <h:outputText value="笔数"/>
        </f:facet>
        <h:outputText value="#{costInfo.costCount}"/>
    </p:column>

    <p:column style="text-align:center" sortBy="#{costInfo.price}">
        <f:facet name="header">
            <h:outputText value="金额"/>
        </f:facet>
        <h:outputText value="#{costInfo.price}">
            <f:convertNumber pattern="##################.##"/>
        </h:outputText>
    </p:column>

    <p:column style="text-align:center" filterBy="#{costInfo.taxAuthority}" filterMatchMode="contains">
        <f:facet name="header">
            <h:outputText value="税务机关"/>
        </f:facet>
        <h:outputText value="#{costInfo.taxAuthority}"/>
        <f:facet name="footer">
            <h:outputText value="笔数：#{fn:length(costAction.costInfos)}"/>
        </f:facet>
    </p:column>

    <p:column style="text-align:center" filterBy="#{costInfo.taxerManager}" filterMatchMode="contains">
        <f:facet name="header">
            <h:outputText value="税管员"/>
        </f:facet>
        <h:outputText value="#{costInfo.taxerManager}"/>
        <f:facet name="footer">
            <h:commandLink>
                <h:outputText value="[导出数据]"/>
                <p:dataExporter type="xls" target="tabSum" fileName="cblzhz"/>
            </h:commandLink>
        </f:facet>
    </p:column>
</p:dataTable>
<br/>
<p:separator/>
<p:dataTable id="tabDetail" style="width:100%;"
             value="#{costAction.thCosts}"
             var="thcost"
             paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
             paginator="true"
             paginatorPosition="bottom"
             rows="15"
             rowsPerPageTemplate="100,50,30,15,5"
             emptyMessage="数据记录为空..."
             widgetVar="tabDetailVar">
    <f:facet name="header">
        <f:facet name="header">
            <h:outputText value="成本项目信息"/>
        </f:facet>

    </f:facet>

    <p:column style="text-align:center" sortBy="#{thcost.invoiceId}">
        <f:facet name="header">
            <h:outputText value="发票号"/>
        </f:facet>
        <h:outputText value="#{thcost.invoiceId}"/>
    </p:column>

    <p:column style="text-align:center">
        <f:facet name="header">
            <h:outputText value="开票项目"/>
        </f:facet>
        <h:outputText value="#{thcost.invoiceItem}"/>
    </p:column>

    <p:column style="text-align:center">
        <f:facet name="header">
            <h:outputText value="开票内容"/>
        </f:facet>
        <h:outputText value="#{thcost.invoiceDetail}"/>
    </p:column>
    <p:column style="text-align:center" sortBy="#{thcost.invoiceAmount}">
        <f:facet name="header">
            <h:outputText value="发票金额"/>
        </f:facet>
        <h:outputText value="#{thcost.invoiceAmount}">
            <f:convertNumber pattern="##################.##"/>
        </h:outputText>
    </p:column>

    <p:column style="text-align:center">
        <f:facet name="header">
            <h:outputText value="开票单位证件号"/>
        </f:facet>
        <h:outputText value="#{thcost.payerId}"/>
    </p:column>
    <p:column style="text-align:center" filterBy="#{thcost.payerName}" filterMatchMode="contains">
        <f:facet name="header">
            <h:outputText value="开票单位名称"/>
        </f:facet>
        <h:outputText value="#{thcost.payerName}"/>
        <f:facet name="footer">
            <h:outputText style="margin-left: 20px;" value="笔数：#{fn:length(costAction.thCosts)}"/>
        </f:facet>
    </p:column>
    <p:column style="text-align:center" sortBy="#{thcost.inputDate}">
        <f:facet name="header">
            <h:outputText value="录入日期"/>
        </f:facet>
        <h:outputText value="#{thcost.inputDate}">
            <f:convertDateTime pattern="yyyy-MM-dd" timeZone="GMT+8" locale="cn"></f:convertDateTime>
        </h:outputText>
        <f:facet name="footer">
            <h:commandLink>
                <h:outputText value="[导出数据]"/>
                <p:dataExporter type="xls" target="tabDetail" fileName="cbxmxx"/>
            </h:commandLink>
        </f:facet>
    </p:column>
</p:dataTable>
</h:form>
</div>
</ui:define>
</ui:composition>